package com.chuangjiang.wxpayx.wxpayx.util;


import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.time.DateFormatUtils;

import java.util.Date;
import java.util.UUID;

public class Util {

    /**
     * 生成时间戳
     * @return
     */
    private static  String createTimestamp(){
        return  Long.toString(System.currentTimeMillis()/1000);
    }

    /**
     * 生成随机字符串
     * @return
     */
    public static String createNonceStr(){
        return UUID.randomUUID().toString();
    }

    public static String cardNo() {
        StringBuilder cardNo = new StringBuilder();
        cardNo.append("CJ");

        cardNo.append(RandomUtils.nextInt(0, 10));
        cardNo.append(RandomUtils.nextInt(0, 10));
        cardNo.append(RandomUtils.nextInt(0, 10));
        cardNo.append(RandomUtils.nextInt(0, 10));

        String time = DateFormatUtils.format(new Date(), "HHmmss");
        cardNo.append(time);
        return cardNo.toString();
    }
}
